using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.InteropServices;

using ILRuntime.CLR.TypeSystem;
using ILRuntime.CLR.Method;
using ILRuntime.Runtime.Enviorment;
using ILRuntime.Runtime.Intepreter;
using ILRuntime.Runtime.Stack;
using ILRuntime.Reflection;
using ILRuntime.CLR.Utils;
using System.Linq;

namespace ILRuntime.Runtime.Generated
{
    unsafe class huqiang_Pool_InstanceContext_Binding
    {
        public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
        {
            BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;
            MethodBase method;
            FieldInfo field;
            Type[] args;
            Type type = typeof(huqiang.Pool.InstanceContext);

            field = type.GetField("Instance", flag);
            app.RegisterCLRFieldGetter(field, get_Instance_0);
            app.RegisterCLRFieldSetter(field, set_Instance_0);
            app.RegisterCLRFieldBinding(field, CopyToStack_Instance_0, AssignFromStack_Instance_0);
            field = type.GetField("Id", flag);
            app.RegisterCLRFieldGetter(field, get_Id_1);
            app.RegisterCLRFieldSetter(field, set_Id_1);
            app.RegisterCLRFieldBinding(field, CopyToStack_Id_1, AssignFromStack_Id_1);
            field = type.GetField("Type", flag);
            app.RegisterCLRFieldGetter(field, get_Type_2);
            app.RegisterCLRFieldSetter(field, set_Type_2);
            app.RegisterCLRFieldBinding(field, CopyToStack_Type_2, AssignFromStack_Type_2);
            field = type.GetField("buffer", flag);
            app.RegisterCLRFieldGetter(field, get_buffer_3);
            app.RegisterCLRFieldSetter(field, set_buffer_3);
            app.RegisterCLRFieldBinding(field, CopyToStack_buffer_3, AssignFromStack_buffer_3);
            field = type.GetField("Index", flag);
            app.RegisterCLRFieldGetter(field, get_Index_4);
            app.RegisterCLRFieldSetter(field, set_Index_4);
            app.RegisterCLRFieldBinding(field, CopyToStack_Index_4, AssignFromStack_Index_4);


            app.RegisterCLRCreateDefaultInstance(type, () => new huqiang.Pool.InstanceContext());
            app.RegisterCLRCreateArrayInstance(type, s => new huqiang.Pool.InstanceContext[s]);

            args = new Type[]{};
            method = type.GetConstructor(flag, null, args, null);
            app.RegisterCLRMethodRedirection(method, Ctor_0);

        }



        static object get_Instance_0(ref object o)
        {
            return ((huqiang.Pool.InstanceContext)o).Instance;
        }

        static StackObject* CopyToStack_Instance_0(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = ((huqiang.Pool.InstanceContext)o).Instance;
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static void set_Instance_0(ref object o, object v)
        {
            ((huqiang.Pool.InstanceContext)o).Instance = (UnityEngine.GameObject)v;
        }

        static StackObject* AssignFromStack_Instance_0(ref object o, ILIntepreter __intp, StackObject* ptr_of_this_method, IList<object> __mStack)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            UnityEngine.GameObject @Instance = (UnityEngine.GameObject)typeof(UnityEngine.GameObject).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            ((huqiang.Pool.InstanceContext)o).Instance = @Instance;
            return ptr_of_this_method;
        }

        static object get_Id_1(ref object o)
        {
            return ((huqiang.Pool.InstanceContext)o).Id;
        }

        static StackObject* CopyToStack_Id_1(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = ((huqiang.Pool.InstanceContext)o).Id;
            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value = result_of_this_method;
            return __ret + 1;
        }

        static void set_Id_1(ref object o, object v)
        {
            ((huqiang.Pool.InstanceContext)o).Id = (System.Int32)v;
        }

        static StackObject* AssignFromStack_Id_1(ref object o, ILIntepreter __intp, StackObject* ptr_of_this_method, IList<object> __mStack)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            System.Int32 @Id = ptr_of_this_method->Value;
            ((huqiang.Pool.InstanceContext)o).Id = @Id;
            return ptr_of_this_method;
        }

        static object get_Type_2(ref object o)
        {
            return ((huqiang.Pool.InstanceContext)o).Type;
        }

        static StackObject* CopyToStack_Type_2(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = ((huqiang.Pool.InstanceContext)o).Type;
            __ret->ObjectType = ObjectTypes.Long;
            *(long*)&__ret->Value = result_of_this_method;
            return __ret + 1;
        }

        static void set_Type_2(ref object o, object v)
        {
            ((huqiang.Pool.InstanceContext)o).Type = (System.Int64)v;
        }

        static StackObject* AssignFromStack_Type_2(ref object o, ILIntepreter __intp, StackObject* ptr_of_this_method, IList<object> __mStack)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            System.Int64 @Type = *(long*)&ptr_of_this_method->Value;
            ((huqiang.Pool.InstanceContext)o).Type = @Type;
            return ptr_of_this_method;
        }

        static object get_buffer_3(ref object o)
        {
            return ((huqiang.Pool.InstanceContext)o).buffer;
        }

        static StackObject* CopyToStack_buffer_3(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = ((huqiang.Pool.InstanceContext)o).buffer;
            object obj_result_of_this_method = result_of_this_method;
            if(obj_result_of_this_method is CrossBindingAdaptorType)
            {    
                return ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance);
            }
            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }

        static void set_buffer_3(ref object o, object v)
        {
            ((huqiang.Pool.InstanceContext)o).buffer = (huqiang.Pool.ModelBuffer)v;
        }

        static StackObject* AssignFromStack_buffer_3(ref object o, ILIntepreter __intp, StackObject* ptr_of_this_method, IList<object> __mStack)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            huqiang.Pool.ModelBuffer @buffer = (huqiang.Pool.ModelBuffer)typeof(huqiang.Pool.ModelBuffer).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags)0);
            ((huqiang.Pool.InstanceContext)o).buffer = @buffer;
            return ptr_of_this_method;
        }

        static object get_Index_4(ref object o)
        {
            return ((huqiang.Pool.InstanceContext)o).Index;
        }

        static StackObject* CopyToStack_Index_4(ref object o, ILIntepreter __intp, StackObject* __ret, IList<object> __mStack)
        {
            var result_of_this_method = ((huqiang.Pool.InstanceContext)o).Index;
            __ret->ObjectType = ObjectTypes.Integer;
            __ret->Value = result_of_this_method;
            return __ret + 1;
        }

        static void set_Index_4(ref object o, object v)
        {
            ((huqiang.Pool.InstanceContext)o).Index = (System.Int32)v;
        }

        static StackObject* AssignFromStack_Index_4(ref object o, ILIntepreter __intp, StackObject* ptr_of_this_method, IList<object> __mStack)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            System.Int32 @Index = ptr_of_this_method->Value;
            ((huqiang.Pool.InstanceContext)o).Index = @Index;
            return ptr_of_this_method;
        }



        static StackObject* Ctor_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject* __ret = ILIntepreter.Minus(__esp, 0);

            var result_of_this_method = new huqiang.Pool.InstanceContext();

            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
        }


    }
}
